<template>
    <div class="form_box" v-loading="edit.loading">
        <el-form :model="edit.info"
                 :rules="rules"
                 v-if="!edit.loading"
                 ref="formRef">

            <el-form-item prop="handle" label=" ">
                <mi-radio v-model="edit.info.handle" :options="[{id:'inc',title:'增加'}, {id:'dec', title:'减少'}]"></mi-radio>
            </el-form-item>

            <el-form-item prop="amount" label="数量">
                <mi-input-number v-model="edit.info.amount" />
            </el-form-item>

            <el-form-item prop="note" label="备注">
                <mi-input v-model="edit.info.note" />
            </el-form-item>

        </el-form>
    </div>
    <div class="d_flex flex_jc_end" style="position: sticky; left: 0; bottom: 0;">
        <el-button type="primary" @click="submit" :loading="edit.loading">保存信息</el-button>
    </div>
</template>

<script setup lang="ts">
import {ref, onBeforeMount, inject, reactive} from "vue";
import {FormInstance} from "element-plus";
import Edit from "@/model/edit";

const rules = {
    handle:[{required:true, message:'必填'}],
    amount:[{required:true, message:'必填'}],
}

const props = withDefaults(defineProps<{
    model:string,
    info:Record<string, any>,
}>(),{})

const list = inject("list")
const edit = inject('setAccount', new Edit({}))
const formRef = ref<FormInstance>()


const submit = () => {
    const {info} = props
    edit.info.user_id = info.id
    edit.submit({
        formRef: formRef.value,
        url: '/site.user/setAccount',
    })
}


</script>

<style scoped>

</style>
